# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
%YAML 1.2
---
$id: "http://devicetree.org/schemas/soc/qcom/qcom,apr.yaml#"
$schema: "http://devicetree.org/meta-schemas/core.yaml#"

title: Qualcomm APR/GPR (Asynchronous/Generic Packet Router)

maintainers:
  - Srinivas Kandagatla <srinivas.kandagatla@linaro.org>

description: |
  This binding describes the Qualcomm APR/GPR, APR/GPR is a IPC protocol for
  communication between Application processor and QDSP. APR/GPR is mainly
  used for audio/voice services on the QDSP.

properties:
  compatible:
    enum:
      - qcom,apr
      - qcom,apr-v2
      - qcom,gpr

  power-domains:
    maxItems: 1

  qcom,apr-domain:
    $ref: /schemas/types.yaml#/definitions/uint32
    enum: [1, 2, 3, 4, 5, 6, 7]
    description:
      Selects the processor domain for apr
        1 = APR simulator
        2 = PC Domain
        3 = Modem Domain
        4 = ADSP Domain
        5 = Application processor Domain
        6 = Modem2 Domain
        7 = Application Processor2 Domain
    deprecated: true

  qcom,domain:
    $ref: /schemas/types.yaml#/definitions/uint32
    minimum: 1
    maximum: 7
    description:
      Selects the processor domain for apr
        1 = APR simulator
        2 = PC Domain
        3 = Modem Domain
        4 = ADSP Domain
        5 = Application processor Domain
        6 = Modem2 Domain
        7 = Application Processor2 Domain
      Selects the processor domain for gpr
        1 = Modem Domain
        2 = Audio DSP Domain
        3 = Application Processor Domain

  qcom,glink-channels:
    $ref: /schemas/types.yaml#/definitions/string-array
    description: Channel name used for the communication
    maxItems: 1

  qcom,intents:
    $ref: /schemas/types.yaml#/definitions/uint32-array
    description:
      List of (size, amount) pairs describing what intents should be
      preallocated for this virtual channel. This can be used to tweak the
      default intents available for the channel to meet expectations of the
      remote.

  qcom,smd-channels:
    $ref: /schemas/types.yaml#/definitions/string-array
    description: Channel name used for the communication
    items:
      - const: apr_audio_svc

  '#address-cells':
    const: 1

  '#size-cells':
    const: 0

patternProperties:
  "^service@[1-9a-d]$":
    type: object
    $ref: /schemas/soc/qcom/qcom,apr-services.yaml
    additionalProperties: true
    description:
      APR/GPR static port services.

    properties:
      compatible:
        enum:
          - qcom,q6core
          - qcom,q6asm
          - qcom,q6afe
          - qcom,q6adm
          - qcom,q6apm
          - qcom,q6prm

required:
  - compatible
  - qcom,domain

allOf:
  - if:
      properties:
        compatible:
          enum:
            - qcom,gpr
    then:
      properties:
        qcom,glink-channels:
          items:
            - const: adsp_apps
        power-domains: false
    else:
      properties:
        qcom,glink-channels:
          items:
            - const: apr_audio_svc

  - if:
      required:
        - qcom,glink-channels
    then:
      properties:
        qcom,smd-channels: false

  - if:
      required:
        - qcom,smd-channels
    then:
      properties:
        qcom,glink-channels: false

additionalProperties: false

examples:
  - |
    #include <dt-bindings/soc/qcom,apr.h>
    apr {
        compatible = "qcom,apr-v2";
        qcom,domain = <APR_DOMAIN_ADSP>;
        qcom,glink-channels = "apr_audio_svc";
        qcom,intents = <512 20>;
        #address-cells = <1>;
        #size-cells = <0>;

        q6core: service@3 {
            compatible = "qcom,q6core";
            reg = <APR_SVC_ADSP_CORE>;
            qcom,protection-domain = "avs/audio", "msm/adsp/audio_pd";
        };

        service@4 {
            compatible = "qcom,q6afe";
            reg = <APR_SVC_AFE>;
            qcom,protection-domain = "avs/audio", "msm/adsp/audio_pd";

            clock-controller {
                compatible = "qcom,q6afe-clocks";
                #clock-cells = <2>;
            };

            dais {
                compatible = "qcom,q6afe-dais";
                #address-cells = <1>;
                #size-cells = <0>;
                #sound-dai-cells = <1>;
                /* ... */
            };
            /* ... */
        };
    };

  - |
    #include <dt-bindings/soc/qcom,gpr.h>
    gpr {
        compatible = "qcom,gpr";
        qcom,domain = <GPR_DOMAIN_ID_ADSP>;
        qcom,glink-channels = "adsp_apps";
        qcom,intents = <512 20>;
        #address-cells = <1>;
        #size-cells = <0>;

        service@1 {
            compatible = "qcom,q6apm";
            reg = <GPR_APM_MODULE_IID>;
            #sound-dai-cells = <0>;
            qcom,protection-domain = "avs/audio", "msm/adsp/audio_pd";

            dais {
                compatible = "qcom,q6apm-dais";
                iommus = <&apps_smmu 0x1801 0x0>;
            };

            bedais {
                compatible = "qcom,q6apm-lpass-dais";
                #sound-dai-cells = <1>;
            };
        };
    };
